/*
 * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.inspur.edp.bff.designtime.generator.core.rtgen.managergenerator.assemblermgr;

import com.inspur.edp.bff.designtime.generator.core.rtgen.managergenerator.FSMgrGeneratorContext;
import com.inspur.edp.bff.spi.assembler.AbstractAssemblerManager;
import com.inspur.edp.caf.generator.baseInfo.TypeInfo;
import com.inspur.edp.caf.generator.item.ClassGenerator;
import com.inspur.edp.caf.generator.item.ClassGeneratorContext;
import com.inspur.edp.caf.generator.property.ClassPropertyGenerator;
import com.inspur.edp.cef.gencommon.MediateType;
import com.inspur.edp.cef.generator.overall.GeneratorUtil;
import org.eclipse.jdt.core.dom.Modifier;

import java.util.ArrayList;

public class AssemblerMgrGenerator extends ClassGenerator {
    private FSMgrGeneratorContext mgrGenContext;

    public AssemblerMgrGenerator(FSMgrGeneratorContext mgrGenContext) {
        super(mgrGenContext.getFSGeneratorContext().getCompilationUnitInfo());
        this.mgrGenContext = mgrGenContext;
    }

    protected final String GetNameSpace() {
        return mgrGenContext.getFSGeneratorContext().getNameSpace();
    }

    @Override
    protected void afterInitialize() {
        super.afterInitialize();
        MediateType tempVar = new MediateType(GetNameSpace(), getName());
        mgrGenContext.setAssemblerMgrContext(tempVar);
    }

    @Override
    protected final String getName() {
        return GeneratorUtil.getName(mgrGenContext.getFSGeneratorContext().getVmGenContext().getVm().getCode()) + "AssemblerManager";
    }

    @Override
    protected TypeInfo setParentClass() {
        return new TypeInfo(AbstractAssemblerManager.class);
    }

    @Override
    protected ClassGeneratorContext createClassInfoContext() {
        return new ClassGeneratorContext();
    }

    @Override
    protected final ArrayList<Modifier.ModifierKeyword> getAccessModifier() {
        return new java.util.ArrayList<Modifier.ModifierKeyword>(java.util.Arrays.asList(new Modifier.ModifierKeyword[]{Modifier.ModifierKeyword.PUBLIC_KEYWORD}));
    }

//	@Override
//	protected TypeInfo setParentClass()
//	{
//		return new TypeInfo(AbstractExtendSaveAssembler.class);
//	}

    @Override
    protected java.util.ArrayList<ClassPropertyGenerator> createPropertyGenerators() {
        java.util.ArrayList<ClassPropertyGenerator> propertyGens = new java.util.ArrayList<ClassPropertyGenerator>();
        //IExtendQueryAssembler QueryAssembler { get; }
        QueryAssemblerPropGenerator queryAssemblerProp = new QueryAssemblerPropGenerator(mgrGenContext);
        propertyGens.add(queryAssemblerProp);
        //IDataMapperAssembler DataMapperAssembler { get; }
        DataMapAssemblerPropGenerator dataMapProp = new DataMapAssemblerPropGenerator(mgrGenContext);
        propertyGens.add(dataMapProp);

        //IExtendRetrieveAssembler RetrieveAssembler { get; }
        RetrieveAssemblerPropGenerator retrieveProp = new RetrieveAssemblerPropGenerator(mgrGenContext);
        propertyGens.add(retrieveProp);
        //IExtendRetrieveDefaultAssembler RetrieveDefaultAssembler { get; }
        RetrieveDefaultPropGenerator createProp = new RetrieveDefaultPropGenerator(mgrGenContext);
        propertyGens.add(createProp);
        //IExtendDeleteAssembler DeleteAssembler { get; }
        DeleteAssemblerPropGenerator delProp = new DeleteAssemblerPropGenerator(mgrGenContext);
        propertyGens.add(delProp);
        //IChangeMapperAssembler ChangeMapperAssembler { get; }
        ChangeMapPropGenerator changeMapProp = new ChangeMapPropGenerator(mgrGenContext);
        propertyGens.add(changeMapProp);
        //IExtendModifyAssembler ModifyAssembler { get; }
        ModifyAssemblerPropGenerator modifyProp = new ModifyAssemblerPropGenerator(mgrGenContext);
        propertyGens.add(modifyProp);
        //IExtendSaveAssembler SaveAssembler { get; }
        SaveAssemblerPropAssembler saveProp = new SaveAssemblerPropAssembler(mgrGenContext);
        propertyGens.add(saveProp);
        //TODO 暂时没有消息映射扩展
//        MessageMapPropGenerator msgMapProp = new MessageMapPropGenerator(mgrGenContext);
//        propertyGens.add(msgMapProp);
        return propertyGens;
    }
}
